Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deflake amp-form tests #9384

Merged
merged 2 commits into from
May 17, 2017
Merged

Deflake amp-form tests #9384

merged 2 commits into from
May 17, 2017

Conversation

cvializ
Copy link
Contributor

@cvializ cvializ commented May 16, 2017

Fixes #9358

const message = 'Failed to parse response JSON:';
user().error(TAG, message, error);
rethrowAsync(message, error);
user().error(TAG, `Failed to parse response JSON: ${error}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • @jridgewell
    Carlos, Justin:
    do we know why did we had rethrowAsync here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My theory is it was originally there to throw the error outside of the Promise chain so it would show up in the console. Since user().error performs that function too, it was equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope.

return timer.promise(5).then(() => {

return ampForm.xhrSubmitPromiseForTesting().then(() => {
expect(false).to.be.true; // should not run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert.fail('submit should have failed.');

ditto above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I was looking for the right fail pattern, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just throw an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing a plain error is concise, but assert seems more idiomatic for Chai. Any objections to using assert?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants